<template>
	<view class="record">
		<view class="header">
			<view class="left">
				<view class="minus">
					<view class="unit">
						￥
					</view>
					<view class="number">
						{{query.threshold}}
					</view>
				</view>
				<view class="full">
					{{query.threshold_str}}
				</view>
			</view>
			<!-- 虚线 -->
			<view class="height-dotted-line">
			</view>
			<!-- 名称 -->
			<view class="right">
				<view class="name-of-shop">
					<view class="title">
						{{query.title}}
					</view>
					<view class="time">
						<text class="color1">共{{query.quantity}}张</text>
						<view class="gang">
						</view>
						<text class="color1">已领{{query.claim}}张</text>
						<view class="gang">
						</view>
						<text class="color1">剩余{{query.yu}}张</text>
					</view>
				</view>
			</view>
		</view>
		<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="scrolltolower">
			<view class="comlum_Y" v-if="list.length">
				<view v-for="(item,index) in list" :key="index" class="Item">
					<view class="img">
						<image :src="item.avatar" mode="aspectFill" class="avater"></image>
						<image :src="!item.gender ?$IMG_URL('/static/mannager/girl.png'):$IMG_URL('/static/mannager/boy.png')" mode="aspectFill" class="sex"></image>
					</view>
					<view class="right">
						<view class="title">
							{{item.name}}
						</view>
						<view class="bottom">
							<text class="size1" >{{item.time}}</text>
						</view>
					</view>
					<view class="num" :style="{color:item.form?'#F37364':'#333333'}">
						{{item.num_str}}
					</view>
				</view>
				<u-loadmore :status="status" />
			</view>
			<empty v-else :content="'领取记录'"></empty>
		</scroll-view>
	</view>
	</view>
</template>

<script>
	import{
		storeCouponLog
	} from '@/api/manager.js'
	import empty from './components/empty.vue'
	export default {
		components: {
			empty
		},
		data() {
			return {
				status: 'loadmore', //当前状态
				initer:{
					coupon_id:'',
					page:1
				},
				query: {},
				list:[]
			}
		},
		onLoad(e) {
			this.initer.coupon_id = e.coupon_id
			this.getstoreCouponLog()
		},
		methods: {
			scrolltolower(){
				this.initer.page++
				this.getstoreCouponLog()
			},
			getstoreCouponLog(){
				storeCouponLog(this.initer).then(({data:res})=>{
					console.log('res', res);
					if (res.code == 1) {
						this.query = res.data.coupon_info
						this.status = 'loading'
						if (this.query.page > res.data.all_page) {
							console.log('nomore');
							this.status = 'nomore'
							return false
						} else {
							console.log('more');
							this.status = 'more'
							this.list = this.list.concat(res.data.list)
						}
					
						console.log('list', this.list);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #e9e9e9;
	}

	.record {
		display: flex;
		flex-direction: column;
		align-items: center;

		.header {
			width: 100%;
			height: 160rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			background-color: #ffffff;
			.left {
				width: 185rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				padding-left: 32rpx;

				.minus {
					display: flex;
					flex-direction: row;
					align-items: baseline;
					margin-bottom: 2rpx;

					.unit {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Bold;
						font-weight: 700;
						text-align: left;
						color: #f37364;
					}

					.number {
						font-size: 56rpx;
						font-family: DIN, DIN-Bold;
						font-weight: 700;
						text-align: left;
						color: #f37364;
					}
				}

				.full {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: center;
					color: #666666;
				}
			}

			.height-dotted-line {
				width: 0rpx;
				height: 118rpx;
				opacity: 0.1;
				border: 1rpx dashed #333333;
				margin: 0 33rpx;
			}

			.right {
				flex: 1;
				padding-right: 32rpx;
				display: flex;
				flex-direction: row;
				align-items: center;

				.name-of-shop {
					display: flex;
					flex-direction: column;
					flex: 1;

					.title {
						font-size: 32rpx;
						font-family: PingFang SC, PingFang SC-Bold;
						font-weight: 700;
						text-align: left;
						color: #333333;
						margin-bottom: 8rpx;
					}

					.time {
						font-size: 20rpx;
						font-family: PingFang SC, PingFang SC-Regular;
						font-weight: 400;
						display: flex;
						flex-direction: row;
						align-items: center;

						.color1 {
							color: #666666;
						}

						.gang{
							width: 0;
							height: 20rpx;
							border: 1rpx solid #666666;
							margin: 0 15rpx;
						}
					}
				}
			}
		}
		.scroll-Y{
			width: 100%;
			height: 86vh;
			.comlum_Y{
				display: flex;
				flex-direction: column;
				align-items: center;
				padding-top: 24rpx;
				.Item{
					width: 702rpx;
					height: 128rpx;
					background: #ffffff;
					border-radius: 16rpx;
					padding: 0 40rpx 0 24rpx;
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-bottom: 20rpx;
					.img{
						width: 80rpx;
						height: 80rpx;
						background: #f6f6f6;
						border-radius: 50%;
						position: relative;
						margin-right: 20rpx;
						.avater{
							width: 100%;
							height: 100%;
							border-radius: 50%;
						}
						.sex{
							position: absolute;
							right: 0;
							bottom: 0;
							width: 26rpx;
							height: 26rpx;
						}
					}
					.num{
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						color: #333333;
					}
				}
				.right{
					display: flex;
					flex-direction: column;
					flex: 1;
					.title{
						font-size: 32rpx;
						font-family: PingFang SC, PingFang SC-Bold;
						font-weight: 700;
						text-align: left;
						color: #333333;
						margin-bottom: 2rpx;
					}
					.bottom{
						.size1{
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC-Regular;
							font-weight: 400;
							text-align: left;
							color: #000000;
						}
						.size2{
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC-Regular;
							font-weight: 400;
							text-align: left;
							color: #b6b6b6;
						}
					}
				}
			}
		}
	}
</style>